use std::str;
use std::{
    io::{Read, Write},
    net::TcpStream,
};

fn main() {
    // 创建连接
    let mut stream = TcpStream::connect("localhost:3001").unwrap();
    // 向服务器发送消息
    stream.write("hello".as_bytes()).unwrap();
    // 创建buffer读取服务器的返回消息
    let mut buffer = [0; 5];
    stream.read(&mut buffer).unwrap();

    println!("Response from srever is :{:?}", str::from_utf8(&mut buffer))
}
